<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录页面</title>
  <!-- 引入 Element Plus CSS -->
  <link rel="stylesheet" href="https://unpkg.com/element-plus@2.9.5/dist/index.css">
  <!-- 引入 Vue 3 -->
  <script src="https://unpkg.com/vue@3.2.47/dist/vue.global.js"></script>
  <!-- 引入 Element Plus -->
  <script src="https://unpkg.com/element-plus@2.9.5/dist/index.full.js"></script>
  <style>
    .login-container {
      max-width: 400px;
      margin: 50px auto;
      padding: 20px;
      border: 1px solid #ddd;
      border-radius: 8px;
      background-color: #f9f9f9f9;
    }
  </style>
</head>
<body>
  <div id="app" class="login-container">
    <el-form :model="loginForm" ref="loginForm" label-width="80px">
      <el-form-item label="用户名" prop="username" :rules="[{ required: true, message: '请输入用户名', trigger: 'blur' }]">
        <el-input v-model="loginForm.username" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
        <el-input type="password" v-model="loginForm.password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>

  <script>
    const { createApp } = Vue;
    createApp({
      data() {
        return {
          loginForm: {
            username: '',
            password: ''
          }
        };
      },
      methods: {
        login() {
          this.$refs.loginForm.validate((valid) => {
            if (valid) {
              console.log('登录信息：', this.loginForm);
              this.$message.success('登录成功！');
              
            } else {
              console.log('表单验证失败！');
              return false;
            }
          });
        }
      }
    }).use(ElementPlus).mount("#app");
  </script>
</body>
</html>